package com.woniu.finance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.finance.domain.ApartFee;
import com.woniu.finance.service.IApartFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公寓缴费记录Controller
 * 
 * @author yy
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/finance/tbapartfee")
@Api("公寓缴费记录管理")
public class ApartFeeController extends BaseController
{
    @Autowired
    private IApartFeeService apartFeeService;

    /**
     * 查询公寓缴费记录列表
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartfee:list')")
    @GetMapping("/list")
    @ApiOperation("公寓缴费记录分页查询")
    public TableDataInfo list(ApartFee apartFee)
    {
        startPage();
        List<ApartFee> list = apartFeeService.selectApartFeeList(apartFee);
        return getDataTable(list);
    }

    /**
     * 导出公寓缴费记录列表
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartfee:export')")
    @Log(title = "公寓缴费记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("公寓缴费记录导出")
    public void export(HttpServletResponse response, ApartFee apartFee)
    {
        List<ApartFee> list = apartFeeService.selectApartFeeList(apartFee);
        ExcelUtil<ApartFee> util = new ExcelUtil<ApartFee>(ApartFee.class);
        util.exportExcel(response, list, "公寓缴费记录数据");
    }

    /**
     * 获取公寓缴费记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartfee:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据主键查询公寓缴费记录")
    @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(apartFeeService.selectApartFeeById(id));
    }

    /**
     * 新增公寓缴费记录
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartfee:add')")
    @Log(title = "公寓缴费记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加公寓缴费记录")
    public AjaxResult add(@RequestBody ApartFee apartFee)
    {
        return toAjax(apartFeeService.insertApartFee(apartFee));
    }

    /**
     * 修改公寓缴费记录
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartfee:edit')")
    @Log(title = "公寓缴费记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新公寓缴费记录")
    public AjaxResult edit(@RequestBody ApartFee apartFee)
    {
        return toAjax(apartFeeService.updateApartFee(apartFee));
    }

    /**
     * 删除公寓缴费记录
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartfee:remove')")
    @Log(title = "公寓缴费记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除公寓缴费记录")
    @ApiImplicitParam(name = "ids", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(apartFeeService.deleteApartFeeByIds(ids));
    }

    @RequestMapping("/feign/batchAdd")
    public Integer feignBatchAddApartFee(@RequestBody List<ApartFee> apartFeeList){
        return apartFeeService.batchAdd(apartFeeList);
    }
}
